﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ExamTests
{
    [TestClass]
    public class TripleTest
    {
        [TestMethod]
        public void TripleConstructorTest()
        {
            int a = 0;
            int b = 0;
            int c = 0;
            Triple target = new Triple(a, b, c);
        }

        [TestMethod]
        public void op_AdditionTest()
        {
            Triple first = new Triple(3, 5, 12);
            Triple second = new Triple(-1, 22, 1);
            Triple expected = new Triple(2, 27, 13);
            Triple actual = (first + second);
            Assert.AreEqual(actual.A, expected.A);
            Assert.AreEqual(actual.B, expected.B);
            Assert.AreEqual(actual.C, expected.C);
        }

        [TestMethod]
        public void op_IncrementTest()
        {
            Triple triple = new Triple(0, 2, -5);
            Triple expected = new Triple(1, 3, -4);
            Triple actual = ++(triple);
            Assert.AreEqual(actual.A, expected.A);
            Assert.AreEqual(actual.B, expected.B);
            Assert.AreEqual(actual.C, expected.C);
        }

        [TestMethod]
        public void op_SubtractionTest()
        {
            Triple first = new Triple(-2, -3, 19);
            Triple second = new Triple(0, -5, 1);
            Triple expected = new Triple(-2, 2, 18);
            Triple actual = (first - second);
            Assert.AreEqual(actual.A, expected.A);
            Assert.AreEqual(actual.B, expected.B);
            Assert.AreEqual(actual.C, expected.C);
        }

        [TestMethod]
        public void CompareToTestEqual()
        {
            int a = 5;
            int b = 7; 
            int c = 2;
            Triple target = new Triple(a, b, c); 
            Triple other = new Triple(14, 0, 0); 
            int expected = 0;
            int actual = target.CompareTo(other);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void CompareToTestLess()
        {
            int a = 5;
            int b = 7;
            int c = 2;
            Triple target = new Triple(a, b, c);
            Triple other = new Triple(15, 0, 0);
            int actual = target.CompareTo(other);
            if (actual >= 0)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void CompareToTestGreater()
        {
            int a = 5;
            int b = 7;
            int c = 6;
            Triple target = new Triple(a, b, c);
            Triple other = new Triple(15, 0, 0);
            int actual = target.CompareTo(other);
            if (actual <= 0)
            {
                Assert.Fail();
            }
        }

        [TestMethod]
        public void CloneTest()
        {
            Triple target = new Triple(2, 3, 5);
            Triple actual = target.Clone() as Triple;
            Assert.AreEqual(actual.A, target.A);
            Assert.AreEqual(actual.B, target.B);
            Assert.AreEqual(actual.C, target.C);
            Assert.AreNotSame(target, actual);
        }
    }
}
